{include file="public/head" /}
<body>
{include file="public/menu" /}
<div class="recharge">
    <div class="wrap">
        <div class="subnav commonTab">
            <span class="ac">实名认证</span>
        </div>
        <ul id="content">
            <li class="showli">
                <form action="" onSubmit="return false;" id="FromData">
                    <div class="money">
                        <label>真实姓名：</label>
                        {if condition="($member.username) AND ($member.username neq '未认证会员')"}
                        <input type="text" class="recharge-amount amount1" name="username" readonly="readonly" value={$member.username} />
                        {else}
                        <input type="text" class="recharge-amount amount1" name="username" />
                        {/if}
                    </div>
                    <div class="money">
                        <label>身份证号：</label>
                        {if condition="$member.certificate > 1"}
                        <input type="text" class="recharge-amount amount1" name="certificate" readonly="readonly" value={$member.certificate} />
                        {else}
                        <input type="text" class="recharge-amount amount1" name="certificate" />
                        {/if}

                    </div>
                    <!--<div class="money">
                        <label>银行卡号：</label>
                        {if condition="$member.bank_card > 1"}
                        <input type="text" class="recharge-amount amount1" name="bank_card" value={$member.bank_card} />
                        {else}
                        <input type="text" class="recharge-amount amount1" name="bank_card" />
                        {/if}

                    </div>
                    </div>-->
                    <div class="money">
                        <label>登录手机：</label>
                        {if condition="$member.mobile > 1"}
                        <input type="text" class="recharge-amount amount1" name="bank_mobile" readonly="readonly" value={$member.mobile} />
                        {else}
                        <input type="text" class="recharge-amount amount1" name="bank_mobile" />
                        {/if}
                    <div class="money">
                        <label>图形验证：</label>

                        <input type="text" class="recharge-amount amount1" id="txcode">
						<img src="{:captcha_src()}" id="code" alt="captcha" onclick="this.src='{:captcha_src()}?rnd=' + Math.random();" />
                    </div>
                    <div class="money">
                        <label>手机验证：</label>
                        <input type="text" class="recharge-amount amount1" name="mobile_code" />
						<button class='getcode' id="getcode" onclick="getCode()">获取验证码</button>
                    </div>
                    <div class="next next1">
                        <span class="label"></span>
                        <input type="submit" value="确认信息" onclick="checkInfo()">
                    </div>
					<br/>
                </form>
            </li>
        </ul>
    </div>
</div>
{include file="public/foot" /}
</body>
{include file="public/load_bottom" /}
<script>

    function checkInfo() {
        var name = $("input[name='username']").val();
        var certificate = $("input[name='certificate']").val();
        var bank_card = $("input[name='bank_card']").val();
        var bank_mobile = $("input[name='bank_mobile']").val();
        var mobile_code = $("input[name='mobile_code']").val();
        var nameReg = /^(^[\u4e00-\u9fa5]{1,10})(·|·([\u4e00-\u9fa5]*·)|)[\u4e00-\u9fa5]{1,10}$/;
		var phoneReg = /(^1[3|4|5|6|7|8|9]\d{9}$)|(^09\d{8}$)/;
		var cardReg = /(^\d{15}$)|(^\d{17}([0-9]|X|x)$)/;
		var bankReg = /^\d{16}|\d{19}$/;
            if(name == ''){
            layer.msg('真实姓名必填',{time:1000});
			return false;
		}
		if(!nameReg.test(name)){
            layer.msg('请输入真实姓名',{time:1000});
			return false;
		}
		if(!cardReg.test(certificate)){
            layer.msg('请输入正确的身份证信息',{time:1000});
			return false;
		}
		/*if(!bankReg.test(bank_card)){
            layer.msg('请输入正确银行卡号',{time:1000});
			return false;
		}*/
		if(!phoneReg.test(bank_mobile)){
            layer.msg('请输入正确手机号',{time:1000});
			return false;
		}
		/*if(mobile_code == ''){
            layer.msg('手机验证码必填',{time:1000});
			return false;
		}*/
		var index = layer.load(0, {shade: false});
		var fromData = $('#FromData').serialize();
		$.ajax({
			url:"{:url('Member/authentication')}",
			type:"POST",
			dataType:"JSON",
			data:fromData,
			success:function(msg){
				layer.close(index);
				layer.msg(msg.info);
				if(msg.status == 1){
					window.location.href=msg.url;
				}
				return false;
			}
		})		
    }

	function getCode(){
		var code = $("#txcode").val();
		var mobile = $("input[name='bank_mobile']").val();
		var phoneReg = /(^1[3|4|5|6|7|8|9]\d{9}$)|(^09\d{8}$)/;
		if(!phoneReg.test(mobile)){
			layer.msg('请输入正确的手机号');
			return false;
		}
		if(code.length != 4){
			layer.msg('请输入正确图形验证码');
			return false;
		}
		$.ajax({
			url: "{:url('Member/sendcode')}",
			type: "POST",
			dataType: "JSON",
			data: {mobile:mobile,code:code},
			success: function(msg){
				layer.msg(msg.info);
				if(msg.status == 1){
					$('#code').click();
					settime();
				}
				return false;
			}
		})
	}
	var countdown=60;
	function settime(){
		var val = $("#getcode");
		if (countdown == 0) {
			val.attr('disabled',false)
			val.text("获取验证码");
			countdown = 60;
		} else {
			val.attr('disabled',true)
			val.text(countdown+"s");
			countdown--;
			setTimeout(function() {
				settime()
			},1000)
		}

	}
	
	
</script>
</html>